package com.liya.controller;

import com.liya.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * @author LiYa
 * @version 1.0
 * @className UserController
 * @description TODO
 * @science 2020/9/21 16:54
 */
@Controller
@RequestMapping("/user")
public class UserController{

    @RequestMapping(value = "/register",method = RequestMethod.POST)

    public String registerUser(User user, ModelMap map){
        System.out.println(user);
        map.addAttribute("name",user.getName());
        return "userRegisterResult";
    }
    @RequestMapping("/modify")
    public String modifyUser(User user, Model map){
        return null;
    }
    @GetMapping("/getRegisterView")
    public String getRegisterView(){
        return "user";
    }

    @PostMapping("/ajaxcomplex")
    @ResponseBody
    public Map<String,Object> ajaxRegister(User user){
        System.out.println(user);
        Map<String,Object> result = new HashMap<>();


        result.put("code",0);
        result.put("user",user);
        result.put("message","注册成功");
        return result;
    }
}
